﻿var main = document.querySelector(".main");
main.onclick = function (event) {
    var ele = event.target;
    if (ele.nodeName == 'A') {
        var lis = ele.parentElement.parentElement.children;
        for (var i = 0; i < lis.length; i++) {
            lis[i].firstElementChild.style.color = "#5c5c5c";
            lis[i].firstElementChild.className = "";
            ele.parentElement.parentElement.parentElement.parentElement.lastElementChild.lastElementChild.innerText = "";
        }
        ele.style.color = "#FF6000";
        ele.className = "pitch";
        var as = document.querySelectorAll(".pitch");
        for (var j = 0; j < as.length; j++) {
            console.log(as[j].innerText);
            if (as[j].innerText != "所有") {
                if (ele.parentElement.parentElement.parentElement
                    .parentElement.lastElementChild.lastElementChild.innerText == "") {
                    ele.parentElement.parentElement.parentElement.parentElement.lastElementChild.lastElementChild.innerText = as[j].innerText;
                } else {
                    ele.parentElement.parentElement.parentElement.parentElement.lastElementChild.lastElementChild.innerText += "+" + as[j].innerText;
                }
            }
        }
    }
};
/***
 * 使用ajax
 * 加载json文件中的job数据
 */
// let jobsearch;
//
//
//
// if(window.XMLHttpRequest){
//     xhr = new XMLHttpRequest();
// }else{
//     xhr = new ActiveXObject("Microsoft.XMLHTTP");
// }
//
// //打开连接对象
// xhr.open("GET","../data/jobSearch.json",true);
// // 准备连接
// let data;

let data2 = [
    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    },

    {
        "jobName":"药学相关专业实习生",
        "jobCom":"龙灯瑞迪制药有限公司",
        "empType":"异地招聘",
        "minSalary":4000,
        "maxSalary":6000,
        "uploadTime":"01-14"
    }
]
// xhr.onreadystatechange = function () {
//     //判断连接状态
//     if (xhr.readyState == 4 && xhr.status == 200) {
//         //获得json里的内容
//         let jsonData = xhr.responseText;
//         // 将json类型的文件转为js类型的文件
//         data = JSON.parse(jsonData);
//
//         loadJobData(data2);
//     }
// };
// //发送请求
// xhr.send();


// loadJobData(data2);

/**
 * 分页
 */
// showRecord(1,10);
layui.use('laypage', function(){

    var laypage = layui.laypage;

    //执行一个laypage实例
    laypage.render({
        elem: 'joblist1' //注意，这里的 test1 是 ID，不用加 # 号
        ,count: 40 //数据总数，从服务端得到
        , limit: 10                      //每页显示条数
        , limits: [10, 20, 30]
        , curr: 1                        //起始页
        , groups: 5                      //连续页码个数
        , prev: '上一页'                 //上一页文本
        , netx: '下一页'                 //下一页文本
        , first: 1                      //首页文本
        , last: 100                     //尾页文本
        , layout: ['prev', 'page', 'next','limit','refresh','skip']
        ,jump: function(obj, first){

            let pageNo = obj.curr;
            let evePageCount = obj.limit;
            //obj包含了当前分页的所有参数，比如：

            for (let i = (pageNo-1)*evePageCount; i<pageNo*evePageCount-1;i++){
                $("#joblist1").append(
                    ` <div class="job_list_title_div ">
            <div class=" job_list_title1 ">
            <input type="checkbox">
            <a href="../post/positiondetails.html" style="text-decoration: none;font-size: 16px;color: #333">
                <span>${data2[i].jobName}</span>
            </a>
        </div>

        <div class="job_list_title1">
            <a href="" style="text-decoration: none;font-size: 14px;color: #666" >
                <span>${data2[i].jobCom}</span>
            </a>
        </div>

        <div class="job_list_title1" style="font-size: 14px">
            <span>${data2[i].empType}</span>
        </div>

        <div class="job_list_title1" style="font-size: 16px; color: #ff6000">
            <span class="min_salary">${data2[i].minSalary}</span>
            <span>-</span>
            <span class="max_salary">${data2[i].maxSalary}</span>
            <span>/月</span>
        </div>
        <div class="job_list_title1" style="font-size: 14px">
            <span>${data2[i].uploadTime}</span>
        </div>
        </div>`
                )
            }

            // //首次不执行
            // if(!first){
            //     //do something
            // }
        }
    });
});




